package com.game.server.message.proto.execute;

import com.comm.ISession;
import com.game.majiang.logic.LogicClient;
import com.game.majiang.logic.LogicServer;
import com.game.majiang.logic.chexuan.ChexuanPlayer;
import com.game.server.message.proto.in.AbstractBrightCardReq;
import com.game.server.message.proto.out.BrightCardRsp;
import com.game.server.system.AbstractTable;

public class BrightCardReq extends AbstractBrightCardReq {

    @Override
    public void Execute(ISession session) {
        LogicClient client = (LogicClient) LogicServer.getInstance().getClient(session.getId());
        if (client != null&&client.checkClick(msgcode)) {
           AbstractTable abTable = client.getTable();
           if(abTable != null) {
        	   ChexuanPlayer player = (ChexuanPlayer) abTable.getPlayer(client.getUserId());
        	   if(player != null ) {
        		   player.getBrightCard()[this.index] = this.type;
        		   BrightCardRsp rsp = new BrightCardRsp();
        		   rsp.setIndex(this.index);
        		   rsp.setType(this.type);
        		   rsp.setUid(client.getUserId());
        		   abTable.BroadCast(rsp, 2);
        	   }
           }
        }
    }

}
